﻿namespace Beetle.Caching
{
    using Beetle;
    using System;
    using System.Collections;
    using System.Runtime.CompilerServices;

    public class CacheManager
    {
        private CacheManager_a _field_a;
        private Hashtable _field_b;

        public CacheManager() : this(0xea60)
        {
        }

        public CacheManager(int eacheExpiredtime)
        {
            this._field_a = new CacheManager_a();
            this._field_b = new Hashtable(0x400);
            this._field_a.a(this);
            this._field_a.Start(eacheExpiredtime, 0);
        }

        private Class_e a(string A_0)
        {
            lock (this._field_b)
            {
                Class_e _e = (Class_e) this._field_b[A_0];
                if (_e == null)
                {
                    _e = new Class_e();
                    this._field_b[A_0] = _e;
                }
                return _e;
            }
        }

        public object Get(string group, string key)
        {
            return this.a(group).a(key);
        }

        public void Remove(string group, string key)
        {
            this.a(group).b(key);
        }

        public void Set(string group, string key, object data, DateTime expired)
        {
            this.a(group).a(key, data, expired);
        }

        private class CacheManager_a : Task
        {
            [CompilerGenerated]
            private CacheManager _field_a;

            [CompilerGenerated]
            public CacheManager a()
            {
                return this._field_a;
            }

            [CompilerGenerated]
            public void a(CacheManager A_0)
            {
                this._field_a = A_0;
            }

            protected override void Execute()
            {
                object[] array = null;
                lock (this.a()._field_b)
                {
                    array = new object[this.a()._field_b.Keys.Count];
                    this.a()._field_b.Keys.CopyTo(array, 0);
                }
                foreach (object obj2 in array)
                {
                    ((Class_e) this.a()._field_b[obj2]).a();
                }
            }
        }
    }
}

